#! /usr/bin/env sh

# pkdocs
# Pack up the html documentation for the vidprofile suite

ME="[pkdocs ]:"

HTML_TAR="vidprofile-html-docs.tar"
HTML_GZ="vidprofile-html-docs.tar.gz"
HTML_DIR="html"

T2T_TAR="vidprofile-t2t-docs.tar"
T2T_GZ="vidprofile-t2t-docs.tar.gz"
T2T_DIR="src"

PKDOCS_PWD=`pwd`

echo "$ME Executing mkdocs..."
echo
if $PKDOCS_PWD/mkdocs; then :
else
   echo "$ME Couldn't make the docs!"
   echo "$ME Exiting..."
   exit 1

echo "$ME Packing html files..."
cd $PKDOCS_PWD/$HTML_DIR
rm -f $HTML_GZ
if tar -cf $HTML_TAR *.html *.php *.css fig/* && \
   gzip $HTML_TAR && \
   rm -f $HTML_TAR
then :
else
   echo "$ME Couldn't zip the html files!"
   echo "$ME Exiting..."
   exit 1
fi

echo "$ME Packing t2t files..."
cd $PKDOCS_PWD/$T2T_DIR
rm -f $T2T_GZ
if tar -cf $T2T_TAR *.t2t *.html && \
   gzip $T2T_TAR && \
   rm -f $T2T_TAR && \
   mv $T2T_GZ $PKDOCS_PWD/$HTML_DIR
then :
else
   echo "$ME Couldn't zip the t2t files!"
   echo "$ME Exiting..."
   exit 1
fi  

echo "$ME Docs packed!"
echo

exit 0
